import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class CovidGroupingMapper extends Mapper<LongWritable,Text,CovidGroupingBean, Text> {
    @Override
    protected void map(LongWritable key, Text value,Context context) throws IOException, InterruptedException {
        //1:数据预处理
        String[] split = value.toString().split(",");
        System.out.println(split[0]);
        if("".equals(split[0]) || "null".equals(split[0])){
            System.out.println(split);
            return;
        }
        //2:得到K2
        CovidGroupingBean k2 = new CovidGroupingBean();
        k2.setCardid(Integer.parseInt(split[0]));
        k2.setName(split[1]);
        k2.setwages(Integer.parseInt(split[5]));
        k2.setCommision(Integer.parseInt(split[6]));
        k2.setPartid(Integer.parseInt(split[7]));


        //3:得到V2，V2就是V1行文本数据
        context.write(k2,value);
    }
}
